package jsen.tool.ddd.demo.domain.parking;

import jsen.tool.ddd.adapter.infrastructure.specification.ISpecification;
import jsen.tool.ddd.demo.domain.base.DomainObject;
import jsen.tool.ddd.demo.domain.parking.spec.parking.ParkingSpec;
import jsen.tool.ddd.domain.ValueObject;
import lombok.Builder;
import lombok.Getter;

import java.util.Set;

/**
 * @author jsen
 * @date 2021/10/6
 */
@ValueObject(name = "Parking", desc = "车位")
@Getter
@Builder
public class Parking implements DomainObject {
    private final ISpecification<Parking> strict = new ParkingSpec();
    private final Location location;

    public boolean hasCar(Set<Car> carList) {
        for (Car car : carList) {
            if (location.isMixWith(car.getLocation())) {
                return true;
            }
        }
        return false;
    }
}
